#ifndef LOBBY_HPP
#define LOBBY_HPP

#include <QWidget>
#include <QGridLayout>
#include <QPushButton>
#include <QTreeWidget>
#include <QListWidget>
#include <QTextEdit>
#include <QLineEdit>
#include <QDockWidget>

#include "client.hpp"
#include "mainwindow.hpp"

class Client;
class MainWindow;

class Lobby : public QWidget
{
    Q_OBJECT

public:
    Lobby(Client * client, MainWindow * parent = 0);
    void displayMessage(const QString & message);

private:
    Client * _client;
    MainWindow * _mainWindow;

    QPushButton * _newGame;
    QTreeWidget * _listGames;
    QListWidget * _listPlayers;
    QTextEdit * _listMessages;
    QLineEdit * _message;
    QPushButton * _send;

    QDockWidget * _dockPlayers;
    QDockWidget * _dockChat;
    QDockWidget * _dockGames;

    QWidget * _dockPlayersContent;
    QWidget * _dockChatContent;
    QWidget * _dockGamesContent;

    QGridLayout * _layoutPlayers;
    QGridLayout * _layoutChat;
    QGridLayout * _layoutGames;

    QLabel * _playersTitle;
    QLabel * _chatTitle;
    QLabel * _gamesTitle;

    QStringList _listPlayerNames;

signals:

public slots:
    void setClients(const QStringList & list);
    void addClient(const QString & name);
    void removeClient(const QString & name);

    void addMessage(const QString & message);
    void sendMessage();

    void addGame(quint8 id, quint8 goban, qreal komi, const QString & black, const QString & white = "");
    void setWhite(quint8 id, const QString & white);
    void removeGame(quint8);

    void showDocks();
    void hideDocks();

private slots:
    void reactNewGame();
    void reactGameListClicked(QModelIndex qmi);
};

#endif // LOBBY_HPP
